package com.tekj.cxqcb.view.Module.activity;

import android.content.DialogInterface;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;


import com.tekj.cxqcb.MainBActivity;
import com.tekj.cxqcb.R;
import com.tekj.cxqcb.operation.BusinessDao;
import com.tekj.cxqcb.operation.resultBean.PubStatusBean;

import butterknife.BindView;
import butterknife.OnClick;
import common.base.activity.BaseActivity;
import common.base.operationHelper.Bean.BindingViewBean;
import common.tool.Tools;
import es.dmoral.toasty.Toasty;

/**
 * 反馈
 */
public class FeedbackActivity extends BaseActivity {
    @BindView(R.id.img_back)
    ImageView imgBack;
    @BindView(R.id.tv_l)
    TextView tvL;
    @BindView(R.id.ll_back)
    LinearLayout llBack;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.iv_r)
    ImageView ivR;
    @BindView(R.id.tv_r)
    TextView tvR;
    @BindView(R.id.ll_right)
    LinearLayout llRight;
    @BindView(R.id.rl_title_bg)
    RelativeLayout rlTitleBg;
    @BindView(R.id.et_content)
    EditText etContent;
    @BindView(R.id.tv_submit)
    TextView tvSubmit;

    BusinessDao businessDao;

    @Override
    public void init() {
        tvTitle.setText("意见反馈");
        businessDao = new BusinessDao(this, this);
    }

    @Override
    public int setLayout() {
        return R.layout.activity_problem_feedback;
    }

    @Override
    public void initLoadStart() {
        showDialog();
    }

    @Override
    public void initLoadEnd() {

        dialog.dismiss();
    }

    @Override
    public void initBindingView(Object mBean) {
        BindingViewBean bindingViewBean = (BindingViewBean) mBean;
        switch (bindingViewBean.getmEnumStatus()) {
            case 意见反馈:
                PubStatusBean pubStatusBean = (PubStatusBean) bindingViewBean.getBean();
                if (pubStatusBean.getCode().equals("0000000")) {
                    finish();
                }
                Toasty.normal(activity, pubStatusBean.getMsg()).show();
                break;
        }
    }


    @OnClick({R.id.ll_back, R.id.tv_submit})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ll_back:
                finish();
                break;
            case R.id.tv_submit:
                if (!etContent.getText().toString().trim().equals(""))
                    Tools.showNormalDialogOne(activity, "意见反馈", "是否提交反馈", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            businessDao.InsertFeedback(MainBActivity.User.getUserId(), etContent.getText().toString().trim());
                        }
                    }, null);

                break;
        }
    }
}
